<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/util.js"></script>
    <script src="/html/js/ajax.js"></script>
    <title>添加页面</title>
</head>
<script>

    async function add() {
        let params = {
            name: $("name").value,
            pwd: $("pwd").value,
            money: $("money").value,
            email: $("email").value,
            phone: $("email").value
        };
        let info = await ajaxPost("/userMan/add", params);
        console.log(info);
        console.log(typeof info);

        let array = document.getElementsByClassName("errorInfo");
        for (let x = 0; x < array.length; x++) {
            array[x].innerHTML = "";
        }

        for (let i = 0; i < info.length; i++) {
            let obj = info[i];
            $(obj.field + "Div").innerHTML = obj.defaultMessage;
        }
    }


    async function add() {
        let params = {
            // name: $("name").value,
            pwd: $("pwd").value,
            money: $("money").value
            // email: $("email").value,
            // phone: $("email").value
        };
        let info = await ajaxPost("/userMan/update", params);
        console.log(info);
        console.log(typeof info);

        let array = document.getElementsByClassName("errorInfo");
        for (let x = 0; x < array.length; x++) {
            array[x].innerHTML = "";
        }

        for (let i = 0; i < info.length; i++) {
            let obj = info[i];
            $(obj.field + "Div").innerHTML = obj.defaultMessage;
        }
    }

</script>


<body>
姓名 <input type="text" id="name">
<div id="nameDiv" class="errorInfo"></div>
<br>
密码 <input type="text" id="pwd">
<div id="pwdDiv" class="errorInfo"></div>
<br>
工资 <input type="text" id="money">
<div id="moneyDiv" class="errorInfo"></div>
<br>
邮箱 <input type="text" id="email">
<div id="emailDiv" class="errorInfo"></div>
<br>
电话 <input type="text" id="phone">
<div id="phoneDiv"></div>
<br>
<input type="button" value="点击添加" onclick="add()">

<hr>

请输入新密码：<input type="text" id="newpwd"><br>
<div id="newpwdDiv" class="errorInfo"></div>
请输入新工资：<input type="text" id="newmoney"><br>
<div id="newmoneyDiv" class="errorInfo"></div>
<input type="button" value="添加" onclick="update()">


</body>
</html>